<?php

namespace app\common\model\printmanager;

use think\Model;


class Org extends Model
{

    

    

    // 表名
    protected $name = 'self_printing_org';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text',
        'user_info',
    ];
    

    
    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getUserInfoAttr($value, $data){
        $value = isset($data['user_id']) ? $data['user_id'] : 0;
        return $value ? \app\common\model\User::getBaseInfoNosense($value) : '';
    }

    public function getAddressDetailAttr($value,$data){
        $county_id = isset($data['county_id']) ? $data['county_id'] : 0;
        $detail = isset($data['address']) ? $data['address'] : '';
        $addressInfo = $county_id ? \app\common\model\Area::getAddressByCountyId($county_id) : "";
        return $addressInfo.$detail;
    }

}
